fix(migration): stream exports and externalize historical large files#1238
Open
wafo210715 wants to merge 2 commits into
Open
fix(migration): stream exports and externalize historical large files#1238wafo210715 wants to merge 2 commits into
wafo210715 wants to merge 2 commits into
Conversation
- AdmZip → archiver 流式写入,避免大工作区导出时全量载入内存 - 新增 MIGRATION_BLOCKED_DIRS,跳过 node_modules/.git/dist 等构建目录 - 新增 MAX_EXPORT_FILE_SIZE (50MB),导出时跳过超大文件并告警 - includeWorkspaceData 默认关闭,工作区文件仅在用户勾选时导出 - MigrationSettings 增加「包含会话工作区文件」开关
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Backup export had repeatedly failed with a generic Electron IPC-style “Error invoking remote method 'migration:exportV2': RangeError: Array buffer allocation failed” message.
(以下截图为商业版)

After multiple controlled tests, the failure was narrowed down to historical large files already present in several Agent session workspaces before
64a73f301(fix large file attachment rendering, 2026-05-13). These legacy files included video recordings, geospatial TIFF data, and other large assets that had been physically copied into~/.proma/agent-workspaces.The existing large-file attachment flow prevents newly added files over 100MB from being copied into session workspaces. It does not address these pre-existing copies, which could still make backup export slow, fail, or exhaust memory.
Summary
This PR hardens migration exports against large workspace data and provides a safe migration path for historical files that were copied into Agent session workspaces before
64a73f301(fix large file attachment rendering, 2026-05-13) introduced the current path-backed large-file attachment flow.Export reliability
AdmZipexport creation with streamingarchiveroutput to avoid OOM on large workspaces.node_modules,.git, build outputs, caches, and virtual environments.Historical large-file migration
When users opt into exporting session workspace files, Proma now:
workspace-filesfor files larger than 100MB.~/Documents/Proma-attachmentsby default, preserving workspace/session directory structure.attachedFiles, so they remain available to the Agent without residing under~/.proma.Backup import compatibility
attachedDirectoriesandattachedFilesin import path checks, not only workspace-level config.Manual validation
(以下截图为开源版测试 based on 0.15.3)



Manual validation migrated two historical video files and reclaimed 23GB from
~/.proma. After restarting Proma, three newly added large videos continued to use the existing path-backed attachment flow and remained visible in the session attachment panel.Known limitations / follow-ups
External large attachments are not packaged or compressed into
.proma-backup. This PR treats them as user-managed files under~/Documents/Proma-attachments. Selective sidecar packaging/compression can be considered separately.Historical and newly added large files currently reach the same attachment semantics through different physical paths.
64a73f301.The UI behavior is coherent and subsequent backups are unaffected, but the two storage origins are not yet fully unified. A future cleanup could make this physical layout more elegant without changing the attachment contract.
Validation
bun run typecheckbun run electron:build